package com.ruoyi.logistic.utils;

import java.util.Random;

public class RandomUtil {

    /**
     * 获取随机数
     *
     * @param num 个数
     * @return
     */
    public static String getNumber(int num) {
        String number = "";
        for (int i = 0; i < num; i++) {
            number += (int) (Math.random() * 10);
        }
        return number;
    }

    public static String randomCode() {
        return "" + (new Random().nextInt(899999) + 100000);
    }


    public static String getOutTradeNo() {
        int r1 = (int) (Math.random() * (10));// 产生2个0-9的随机数
        int r2 = (int) (Math.random() * (10));
        long now = System.currentTimeMillis();// 一个13位的时间戳
        String id = String.valueOf(r1) + String.valueOf(r2)
                + String.valueOf(now);// 订单ID
        return id;
    }
}
